package com.weaver.openapi.service;

import com.weaver.openapi.pojo.form.params.*;
import com.weaver.openapi.util.*;
import java.util.*;
import cn.hutool.http.*;
import com.alibaba.fastjson.*;
import com.weaver.openapi.pojo.*;
import com.weaver.openapi.pojo.form.res.*;

public class FormService
{
    public static FormResultVo createFormV2(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("formId", formVo.getFormId());
        paramMap.put("datamap", formVo.getDatamap());
        final String resJson = ((HttpRequest)HttpRequest.post(host + "/form/v2/create").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        return (FormResultVo)JSONObject.parseObject(resJson, (Class)FormResultVo.class);
    }
    
    public static FormResultVo createDataReportByIdValV3(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("formId", formVo.getFormId());
        paramMap.put("jsonStr", formVo.getJsonStr());
        final String resJson = ((HttpRequest)HttpRequest.post(host + "/form/v3/createDataReportByIdVal").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        return (FormResultVo)JSONObject.parseObject(resJson, (Class)FormResultVo.class);
    }
    
    public static MessageResult deleteFormV2(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("reportId", formVo.getReportId());
        final String resJson = ((HttpRequest)HttpRequest.post(host + "/form/v2/delete").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        return (MessageResult)JSONObject.parseObject(resJson, (Class)MessageResult.class);
    }
    
    public static FormResultVo updateFormV2(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("reportId", formVo.getReportId());
        paramMap.put("datamap", formVo.getDatamap());
        final String resJson = ((HttpRequest)HttpRequest.post(host + "/form/v2/update").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        return (FormResultVo)JSONObject.parseObject(resJson, (Class)FormResultVo.class);
    }
    
    public static MessageResult backFormV2(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("reportId", formVo.getReportId());
        final String resJson = ((HttpRequest)HttpRequest.post(host + "/form/v2/back").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        return (MessageResult)JSONObject.parseObject(resJson, (Class)MessageResult.class);
    }
    
    public static FormResultVo classifyFormV2(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        final String resJson = ((HttpRequest)HttpRequest.get(host + "/form/v2/classify").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        return (FormResultVo)JSONObject.parseObject(resJson, (Class)FormResultVo.class);
    }
    
    public static FormResultVo getFormByCategoryIdV2(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("categoryId", formVo.getCategoryId());
        final String resJson = ((HttpRequest)HttpRequest.get(host + "/form/v2/getFormByCategoryId").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (FormResultVo)JSONObject.parseObject(resJson, (Class)FormResultVo.class);
    }
    
    public static FormResultVo getFieldByIdV2(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("id", formVo.getId());
        final String resJson = ((HttpRequest)HttpRequest.get(host + "/form/v2/getFieldById").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (FormResultVo)JSONObject.parseObject(resJson, (Class)FormResultVo.class);
    }
    
    public static FormResultVo getInfoByIDV2(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("id", formVo.getId());
        paramMap.put("pageNo", formVo.getPageNo());
        paramMap.put("pageSize", formVo.getPageSize());
        final String resJson = ((HttpRequest)HttpRequest.get(host + "/form/v2/getInfoByID").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (FormResultVo)JSONObject.parseObject(resJson, (Class)FormResultVo.class);
    }
    
    public static FormResultVo queryDataReportByIdV2(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("id", formVo.getId());
        final String resJson = ((HttpRequest)HttpRequest.get(host + "/form/v2/queryDataReportById").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (FormResultVo)JSONObject.parseObject(resJson, (Class)FormResultVo.class);
    }
    
    public static DataReportResultV3 queryDataReportByIdV3(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("id", formVo.getId());
        final String resJson = ((HttpRequest)HttpRequest.get(host + "/form/v3/queryDataReportById").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (DataReportResultV3)JSONObject.parseObject(resJson, (Class)DataReportResultV3.class);
    }
    
    public static FormResultVo getTodoDataV2(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("pageNo", formVo.getPageNo());
        paramMap.put("pageSize", formVo.getPageSize());
        final String resJson = ((HttpRequest)HttpRequest.get(host + "/form/v2/getTodoData").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (FormResultVo)JSONObject.parseObject(resJson, (Class)FormResultVo.class);
    }
    
    public static FormResultVo getFinfishDataV2(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("pageNo", formVo.getPageNo());
        paramMap.put("pageSize", formVo.getPageSize());
        final String resJson = ((HttpRequest)HttpRequest.get(host + "/form/v2/getFinfishData").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (FormResultVo)JSONObject.parseObject(resJson, (Class)FormResultVo.class);
    }
    
    public static FormResultVo getInfoByIDAndParamV2(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("id", formVo.getId());
        paramMap.put("pageNo", formVo.getPageNo());
        paramMap.put("pageSize", formVo.getPageSize());
        paramMap.put("datamap", formVo.getDatamap());
        final String resJson = ((HttpRequest)HttpRequest.get(host + "/form/v2/getInfoByIDAndParam").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (FormResultVo)JSONObject.parseObject(resJson, (Class)FormResultVo.class);
    }
    
    public static FormResultVo getDataInfoByIDAndParamV2(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("id", formVo.getId());
        paramMap.put("pageNo", formVo.getPageNo());
        paramMap.put("pageSize", formVo.getPageSize());
        paramMap.put("datamap", formVo.getDatamap());
        final String resJson = ((HttpRequest)HttpRequest.post(host + "/form/v2/getDataInfoByIDAndParam").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (FormResultVo)JSONObject.parseObject(resJson, (Class)FormResultVo.class);
    }
    
    public static FormResultVo queryChangedReportsByFormIdV2(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("id", formVo.getId());
        paramMap.put("pageNo", formVo.getPageNo());
        paramMap.put("pageSize", formVo.getPageSize());
        paramMap.put("datamap", formVo.getDatamap());
        final String resJson = ((HttpRequest)HttpRequest.get(host + "/form/v2/queryChangedReportsByFormId").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (FormResultVo)JSONObject.parseObject(resJson, (Class)FormResultVo.class);
    }
    
    public static FormResultVo queryChangedReportsByTypeV2(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("id", formVo.getId());
        paramMap.put("type", formVo.getType());
        paramMap.put("pageNo", formVo.getPageNo());
        paramMap.put("pageSize", formVo.getPageSize());
        paramMap.put("datamap", formVo.getDatamap());
        final String resJson = ((HttpRequest)HttpRequest.get(host + "/form/v2/queryChangedReportsByType").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (FormResultVo)JSONObject.parseObject(resJson, (Class)FormResultVo.class);
    }
    
    public static ChangeFormResultVo queryChangedFormsV2(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("pageNo", formVo.getPageNo());
        paramMap.put("pageSize", formVo.getPageSize());
        paramMap.put("datamap", formVo.getDatamap());
        final String resJson = ((HttpRequest)HttpRequest.get(host + "/form/v2/queryChangedForms").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (ChangeFormResultVo)JSONObject.parseObject(resJson, (Class)ChangeFormResultVo.class);
    }
    
    public static FormResultVo queryChangedFormsByTypeV2(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("type", formVo.getType());
        paramMap.put("pageNo", formVo.getPageNo());
        paramMap.put("pageSize", formVo.getPageSize());
        paramMap.put("datamap", formVo.getDatamap());
        final String resJson = ((HttpRequest)HttpRequest.get(host + "/form/v2/queryChangedFormsByType").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (FormResultVo)JSONObject.parseObject(resJson, (Class)FormResultVo.class);
    }
    
    public static FormResultVo createDataReportByJsonV2(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("formId", formVo.getFormId());
        paramMap.put("dataJson", formVo.getDataJson());
        final String resJson = ((HttpRequest)HttpRequest.post(host + "/form/v2/createDataReportByJson").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (FormResultVo)JSONObject.parseObject(resJson, (Class)FormResultVo.class);
    }
    
    public static FormResultVo getFieldOptionV2(final FormVo formVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", formVo.getAccessToken());
        paramMap.put("userid", formVo.getUserid());
        paramMap.put("formId", formVo.getFormId());
        paramMap.put("fieldId", formVo.getFieldId());
        final String resJson = ((HttpRequest)HttpRequest.get(host + "/api/formdatareport/v2/getFieldOption").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (FormResultVo)JSONObject.parseObject(resJson, (Class)FormResultVo.class);
    }
}
